package com.szpx.controller.twoGroup;


import com.szpx.entity.settingentity.SiteSetting;
import com.szpx.service.SettingsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/setting")
public class SettingsController {
    @Autowired
    private SettingsService settingsService;

    /**
     * 查询所有站点数据
     * @param model
     */
    @GetMapping("/sites")
    public  List<SiteSetting>  getAllSites(Model model){
        List<SiteSetting> siteSettings = settingsService.selectAll();
        model.addAttribute("siteList", siteSettings);
        return siteSettings;
    }
    @PostMapping("/add")
    public String   add(@RequestBody SiteSetting siteSetting){
        settingsService.add(siteSetting);
        return "新增成功";
    }
    @PostMapping("/delete/{id}")
    public String delete(@PathVariable(value = "id") Integer id){
        settingsService.delete(id);
        return "删除成功";
    }
    @PostMapping("/updete/{id}")
    public String update(@RequestBody SiteSetting siteSetting){
        settingsService.update(siteSetting);
        return "修改成功";
    }


}
